import requests
from io import BytesIO
from base64 import b64encode
from retry import retry
import time

def getcontent():
    data = requests.get(f"http://www.aigei.com/user/vcode?dd={int(time.time())}").content
    with open("aigei.png","wb") as f:
        f.write(data)
    return data
@retry()
def getcode(content):
    url = 'http://op.juhe.cn/vercode/index'
    appcode = '9f0057f29dd7806b864772ef2fe22b91'
    datas = {
        'key':appcode,
        'codeType':8002,
        'image':BytesIO(content),
        'base64Str':b64encode(content).decode("utf8"),
        'DTYPE':'json'
    }
    respdata = requests.post(url,data=datas,timeout=40).json()
    if respdata['error_code'] == 0:
        return respdata['result']

res = getcontent()
print("getres")
print(getcode(res))